<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/9/21
  Time: 4:51 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>ss</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="${path}/plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${path}/css/index.css">
</head>
<body>


<%--为了让外部js中出现的项目的上下文路径都是Ok的--%>
<input type='hidden' id='path' value='${path}'>

<%@ include file="../common/nav.jsp" %>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-2">
            <form role="form">
                <div class="form-group">
                    <select id='petTypeSelect' class="form-control">


                        <option value="-1">===宠物类型===</option>

                        <c:forEach items="${types}" var="t">
                            <option
                                    <c:if test="${typeId==t.id}">selected</c:if> value='${t.id}'>${t.name}</option>
                        </c:forEach>
                    </select>

                </div>
            </form>
        </div>
        <div class="col-md-8">
            <div>
                <form class="bs-example bs-example-form" role="form">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="input-group">
                                <input value='${name}' id='search_input' type="text" class="form-control">
                                <span class="input-group-btn">
                                     <button class="btn btn-default" id='search_btn' type="button">搜索</button>
                                    <button type='button' id='more_del_btn' style="margin-left: 5px" class="btn btn-danger">批量删除</button>
                                    <button type="button"  class="btn btn-info" data-toggle="modal" data-target="#myModal">增加宠物</button>
                                 </span>
                            </div><!-- /input-group -->
                        </div><!-- /.col-lg-6 -->
                    </div><!-- /.row -->
                </form>
            </div>
        </div>

        <%--添加宠物模态框--%>
        <%--<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">添加宠物<tton>--%>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">添加宠物</h4>
                    </div>
                    <div class="modal-body">
                        <%--                添加主体--%>
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="name" placeholder="请输入姓名">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">年龄</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="age" placeholder="请输入年龄">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">生日</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="birthday" placeholder="生日格式:yyyy-MM-dd">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">图片</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="picture" placeholder="请输入图片">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">品种</label>
                                <select id="petTypeSelect2" class="form-control" style="width: 50%;margin-left: 19%">
                                    <option value="-1">===宠物类型===</option>

                                    <c:forEach items="${types}" var="t">
                                        <option
                                                <c:if test="${typeId==t.id}">selected</c:if> value='${t.id}'>${t.name}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="add-pets">添加</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div class="container-fluid" style="margin-top: 50px">
    <div class="table-responsive">
        <table class="table table-hover">
            <caption>宠物信息</caption>
            <thead>
            <tr>
                <th><input id='ck_all' type="checkbox"></th>
                <th>序号</th>
                <th>宠物头像</th>
                <th>宠物名称</th>
                <th>宠物年龄</th>
                <th>出生日期</th>
                <th>操作选项</th>
            </tr>
            </thead>
            <tbody id='tb_pet' class='pet'>

            <c:forEach items="${page.list}" var="p" varStatus="vs">
                <tr>
                    <td><input value='${p.id}' name='ck_content' type="checkbox"></td>
                    <td>${vs.count}</td>
                    <td id="td2"><img src='${path}/img/${p.imgUrl}'></td>
                    <td id="td3">${p.name}</td>
                    <td id="td4">${p.age}</td>

                    <td id="td5">${p.birthday}</td>
                    <td><a class="text-danger" href='${path}/pet/del_one?id=${p.id}'><span
                            class="glyphicon glyphicon-trash"></span></a>
                        <button class='btn btn-link' onclick=ajax_del(this,'${p.id}')>异步删除</button>
<%--                        <a class="text-info" href='${path}/pet/findById?id=${p.id}'>修改</a>--%>
                        <button type="button" class='btn btn-info' data-toggle="modal" data-target="#myModal2" onclick=edit('${p.id}')>修改</button>
                    </td>
                </tr>
            </c:forEach>

            <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel2">修改宠物</h4>
                        </div>
                        <div class="modal-body">
                            <%--                添加主体--%>
                            <form class="form-horizontal" role="form">
                                <input type="hidden" id='pet_id'>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="name2" placeholder="输入姓名">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">年龄</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="age2" placeholder="输入年龄">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">生日</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="birthday2" placeholder="生日格式:yy-MM-dd">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">图片</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="picture2" placeholder="请输入图片">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">品种</label>
                                    <select id="petTypeSelect22" class="form-control" style="width: 50%;margin-left: 19%">
                                        <option value="-1">===宠物类型===</option>

                                        <c:forEach items="${types}" var="t">
                                            <option
                                                    <c:if test="${typeId==t.id}">selected</c:if> value='${t.id}'>${t.name}
                                            </option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" id="update-pet">修改</button>
                        </div>
                    </div>
                </div>
            </div>

            </tbody>
        </table>
    </div>
</div>

<%@include file="../common/page.jsp" %>

<script src="${path}/plugins/jquery/jquery.min.js"></script>
<script src="${path}/plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="${path}/js/index.js"></script>
<%--如果js代码是jsp内部代码,那么js中是允许使用EL表达式的,但是如果js是引入的外部,是不允许使用EL表达式的--%>
</body>
</html>

